package edu.towson.cis.cosc490.lab6;


import static android.provider.BaseColumns._ID;
import static edu.towson.cis.cosc490.lab6.Constants.TABLE_NAME;
import static edu.towson.cis.cosc490.lab6.Constants.PRIORITY;
import static edu.towson.cis.cosc490.lab6.Constants.ITEM;
import static edu.towson.cis.cosc490.lab6.Constants.TIME;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class ToDoItemsData extends SQLiteOpenHelper {
	   private static final String DATABASE_NAME = "todoitems.db";
	   private static final int DATABASE_VERSION = 2;

	   /** Create a helper object for the Items database */
	   public ToDoItemsData(Context ctx) { 
	      super(ctx, DATABASE_NAME, null, DATABASE_VERSION);
	   }
	   
	   @Override
	   public void onCreate(SQLiteDatabase db) { 
	      db.execSQL("CREATE TABLE " + TABLE_NAME + " (" + _ID
	            + " INTEGER PRIMARY KEY AUTOINCREMENT, "  
	    		+ PRIORITY + " TEXT NOT NULL," + ITEM + " TEXT NOT NULL, " + TIME + " TEXT NOT NULL);");
	   }

	   @Override
	   public void onUpgrade(SQLiteDatabase db, int oldVersion, 
	         int newVersion) {
	      db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);
	      onCreate(db);
	   }
	}